package sisgel.util;

import java.util.ArrayList;
import sisgel.user.User;

public class DataBase {
	
	static ArrayList<User> db = new ArrayList<User>();

	public static int numberOfUsers() {
		return db.size();
	}
	
	public static int saveUser(User user) {
		db.add(user);
		return db.indexOf(user); // Retornar id do usuario
	}
	
	public static User getUser(String login, String password) {
		User user = null;
		int index = 0;
		final int total = numberOfUsers();
		
		while (index < total) {
			if (db.get(index).login(login,password)) {
				user = db.get(index);
				break;
			}
			
			index++;
		}
		
		return user;
	}
	
}
